using System;
using UnityEngine;

public class Item
{
	public ItemInfo info
	{
		get;
		private set;
	}

	public int count
	{
		get;
		set;
	}

	[Serializable]
	public class Item2
	{
		public string itemInfo;
		public int count;
	}

	public string ToJson()
	{
		Item2 item = new Item2();
		item.itemInfo = info.ToJson();
		item.count = count;
		return JsonUtility.ToJson(item);
	}

	public Item(string json)
	{
		Item2 item = JsonUtility.FromJson<Item2>(json);
		if (item == null) return;
		this.info = new ItemInfo();
		this.info.JsonToObject(item.itemInfo);
		this.count = item.count;
	}

	public Item(ItemInfo info, int count = 1)
	{
		this.info = info;
		this.count = count;
	}

	public virtual bool UsedBy()
	{
		switch (info.type)
		{
			case 1:
				ConstantData.MaxImpulse += info.value;
				break;
			case 3:
				ConstantData.GuidelineLength = 280;
				break;
			case 2:
				ConstantData.angularDrag = 1f;
				break;
		}
		return true;
	}
}
